#include "SkySphereCamera.h"

using namespace OBR;

OptixProgramGroup SkySphereCamera::program_group = nullptr;

SkySphereCamera::SkySphereCamera(float3 _orig)
    : orig(_orig), Camera("shaders/Camera/SkySphereCamera.cu")
{
    this->program_desc.raygen.entryFunctionName = "__raygen__sky_sphere_camera";
    this->program_desc.kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
    this->program_desc.flags = OPTIX_GEOMETRY_FLAG_NONE;
}

SkySphereCamera::~SkySphereCamera()
{
}

void SkySphereCamera::uploadSbtData()
{
    SkySphereCameraData data;
    data.orig = this->orig;
    this->sbt_data.resize(sizeof(SkySphereCameraData));
    this->sbt_data.upload(&data, sizeof(SkySphereCameraData));
}

void SkySphereCamera::_buildFromConfig(const Json::Value &config)
{
    this->medium_idx = config.isMember("medium") ? config["medium"].asUInt() : -1;
    this->orig = make_float3(config["origin"][0].asFloat(), config["origin"][1].asFloat(),
                             config["origin"][2].asFloat());
}

void SkySphereCamera::rotate(float2 deg)
{
}

void SkySphereCamera::translate(float2 dir)
{
}

void SkySphereCamera::zoom(float dist)
{
}

OptixProgramGroupOptions &SkySphereCamera::getProgramGroupOptions()
{
    return this->program_opt;
}

OptixProgramGroupDesc &SkySphereCamera::getProgramGroupDesc()
{
    this->program_desc.raygen.module = this->cuda_module->optix_module;
    return this->program_desc;
}